package org.snail.proxy.server.netty;

import io.netty.channel.Channel;

public class TcpSender {
    private final Channel channel;

    private int port;

    public TcpSender(Channel channel) {
        this.channel = channel;
    }

    public void send(byte[] data) {
        if (channel == null || data == null) {
            return;
        }
        try {
            if (channel.isActive()) {
                channel.write(data);
//                channel.eventLoop().execute(new Write2GatewayWorkRunnable(channel, packet));
            } else {
                channel.close();
//                DLog.LOG_ERROR.debug("发送消息失败{}，连接异常", msg.getClass().getName());
            }
        } catch (Exception e){

        }
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }
}
